package com.xherorlclass.channelHandler;

import com.xherorlclass.channelHandler.handler.MySimpleChannelInboundHandler;
import com.xherorlclass.channelHandler.handler.XherorlRpcRequestEncoder;
import com.xherorlclass.channelHandler.handler.XherorlRpcResponseDecoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

/**
 * @author ：Xherorl
 * @date ：Created in 2023/8/26 9:49
 * @description：
 */
public class ConsumerChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        // netty自带的处理器
        socketChannel.pipeline()
                .addLast(new LoggingHandler(LogLevel.DEBUG))
                // 消息编码器
                .addLast(new XherorlRpcRequestEncoder())
                // 入栈的解码器
                .addLast(new XherorlRpcResponseDecoder())
                // 处理结果
                .addLast(new MySimpleChannelInboundHandler());
    }
}
